package android.meetingatsb.widget

import android.app.DialogFragment
import android.meetingatsb.R
import android.meetingatsb.common.Requirement
import android.meetingatsb.common.User
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window

class MatchUserCompleteFragment : DialogFragment() {
    lateinit var matchUser: User
    lateinit var matchRequirement: Requirement


    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
        val view = inflater!!.inflate(R.layout.dlg_fragment_comment, container, false)
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
        val width = resources.getDimensionPixelSize(R.dimen.popup_width)
        val height = resources.getDimensionPixelSize(R.dimen.popup_height)
        dialog.window!!.setLayout(width, height)
        getData()
        setFragment(view)
        return view
    }

    private fun setFragment(view: View) {
        val fragTran = childFragmentManager.beginTransaction()

        val matchUserInfoFragment = UserInfoFragment()
        val userInfoBundle = Bundle()
        userInfoBundle.putParcelable("user",matchUser)
        matchUserInfoFragment.arguments = userInfoBundle
        fragTran.replace(R.id.match_user_info_fragment, matchUserInfoFragment)

        val matchUserRequirementFragment = RequirementFragment()
        val requirementBundle = Bundle()
        requirementBundle.putParcelable("requirement",matchRequirement)
        matchUserRequirementFragment.arguments = requirementBundle
        fragTran.replace(R.id.match_user_requirement_fragment, matchUserRequirementFragment)

        fragTran.commit()
    }

    private fun setData() {
    }

    private fun bindWidgets() {
    }

    private fun getData() {
        matchUser = arguments.getParcelable("matchUser")
        matchRequirement = arguments.getParcelable("matchRequirement")
    }

}